<?php
$username = $_POST['username'];
$pw = $_POST['pw'];
$cpw = $_POST['cpw'];
$email = $_POST['email'];
$sex = $_POST['sex'];
$fav = implode(',', $_POST['fav']);
/*echo "您输入的 用户名是：$username <br>";
echo "您输入的密码是：$pw <br>";
echo "您输入的重复密码是：$cpw <br>";
echo "您输入的信箱是：$email <br>";
echo "您输入的性别是：";
echo $sex == 1 ? '男' : '女';
echo "<br>";
echo "您选择的爱好是：$fav";*/
//第一步，连接数据库服务器
$conn = mysqli_connect("localhost","root","root","member");
if(!$conn){
die("连接数据库服务器失败");
}
//第二步，设置字符集
mysqli_query($conn,"set names utf8");
//第三步，设置SQL语句
sql = "insert into info (username,pw,sex,email,fav,createTime) values ('username',".md5(pw).",'sex','email','fav','".time()."')";
//第四步，执行SQL查询语句
result = mysqli_query(conn,$sql);
if($result){
echo "alert('数据插入成功'); location.href='index.php';";
}else{
    echo "alert('数据插入失败');history.back();";
}

